﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Linq.Expressions;
using System.Collections.Generic;
using Microsoft.Scripting;
using Microsoft.Scripting.Runtime;

namespace Cjc.ExpressionEngine.Excel
{
	public class ExcelCompiler
	{
		private ExcelContext context;

		public ExcelCompiler( ExcelContext context )
		{
			this.context = context;
		}

		public LambdaExpression ParseSourceCode( CompilerContext compilerContext )
		{
			LambdaExpression expression = null;

			var compiler = new ExcelCompiler( /*compilerContext,*/ context );
			var kind = compilerContext.SourceUnit.Kind;

			if ( kind == SourceCodeKind.Expression )
			{
//				expression = compiler.CompileExpression( compilerContext, ref diagnostics );
			}
/*			else if ( kind == SourceCodeKind.InteractiveCode )
			{
				expression = compiler.CompileProgram( compilerContext, ref diagnostics, ref incompleteInput, true );
			}
			else
			{
				expression = compiler.CompileProgram( compilerContext, ref diagnostics, ref incompleteInput );
			}
			this.CheckDiagnostics( compilerContext, diagnostics );
			if ( incompleteInput )
			{
				compilerContext.SourceUnit.CodeProperties = 4;
				return null;
			}
			if ( expression == null )
			{
				compilerContext.SourceUnit.CodeProperties = 2;
				return null;
			}*/
			return expression;
		}
	}
}